/*Emamul Islam Emon.      Id No: 093-15-844

4)	Example of Another Stack Operation. */

#include<stdio.h>
#include<conio.h>
#define max 100
int stack[max];
int top=-1;
void push(int avalue)
{
if(top<max-1)
stack[top++]=avalue;
else
printf("OVERFLOW!\n");
}
int pop()
{
if(top>=0)
return stack[top--];
else
{
printf("UNDERFLOW!\n");
return-1;
}
}
void show_stack()
{
int i;
printf("Contents of stack:\n");
for(i=top;i>=0;i--)
printf("%d",stack[i]);
printf("\nPress any key to continue....");
getch();
}
main()
{
int option;
int input;
do
{
clrscr();
printf("\t~WELCOME~\n");
printf("STACK PROGRAM DOING BY EMON\n");
printf(".......................\n");
printf(" 1.Push a value onto the stack\n");
printf(" 2.Pop a value from the stack\n");
printf(" 3.Show contents of stack\n");
printf(" 4.Quit\n");
printf(".......................\n");
printf("Enter option(1-4:)");
scanf("%d",&option);
printf("......................\n");
switch(option)
{
case 1:
printf("PUSH:\n");
printf("Enter value:");
scanf("%d",&input);
push(input);
show_stack();
break;
case 2:
printf("POP:\n");
printf("The value %d was popped from stack\n",pop());
case 3:
show_stack();
}
}
while (option!=4);
printf("Quitting....\n");
return 0;
}











































